#define _CRT_SECURE_NO_WARNINGS



//https://www.luogu.com.cn/problem/P1144



#include<iostream>
#include<queue>
#include<cstring>
#include<vector>
using namespace std;
typedef pair<int, int>PII;
const int N = 1e6 + 10, M = 2e6 + 10, MOD = 100003;
int n, m;
vector<int>edges[N];
int dist[N];
bool st[N];
int f[N];

void bfs()
{
	memset(dist, 0x3f, sizeof dist);
	queue<int>q;
	q.push(1);
	dist[1] = 0;
	f[1] = 1;
	//st[1]=true;
	
	while (q.size())
	{
		auto a = q.front();
		q.pop();
		for (auto b : edges[a])
		{
			if (dist[a] + 1 < dist[b])
			{
				dist[b] = dist[a] + 1;
				f[b] = f[a];
				q.push(b);

			}
			else if (dist[a] + 1 == dist[b])
			{
				f[b] = (f[b] + f[a]) % MOD;
			}
		}
	}
}

void dijkstra()
{
	memset(dist, 0x3f, sizeof dist);
	priority_queue<PII, vector<PII>, greater<PII>>heap;
	heap.push({ 0,1 });
	dist[1] = 0;
	f[1] = 1;
	while (heap.size())
	{
		auto t = heap.top();
		heap.pop();
		int a = t.second;
		if (st[a])
			continue;
		st[a] = true;

		for (auto b : edges[a])
		{
			if (dist[a] + 1 < dist[b])
			{
				dist[b] = dist[a] + 1;
				f[b] = f[a];
				heap.push({ dist[b],b });
			}
			else if (dist[a] + 1 == dist[b])
			{
				f[b] = (f[a] + f[b]) % MOD;
			}
		}
	}
}

int main()
{
	//cin>>n>>m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		edges[a].push_back(b);
		edges[b].push_back(a);
	}

	//bfs();
	dijkstra();


	for (int i = 1; i <= n; i++)
	{
		printf("%d\n", f[i]);
	}

	return 0;
}

